class Util {
  constructor() {}
  /* 判断等级 */
  rank(rank_point) {
    let ran_nums = parseInt(rank_point);
    let crown = 0;
    let star = 1;
    if (ran_nums > 50) {
      star = 2;
    }
    if (ran_nums > 200) {
      star = 3;
    }
    if (ran_nums > 500) {
      star = 4;
    }
    if (ran_nums > 1000) {
      crown = 1;
      star = 0;
    }

    if (ran_nums > 2000) {
      crown = 1;
      star = 1;
    }
    if (ran_nums > 3500) {
      crown = 1;
      star = 2;
    }
    if (ran_nums > 5000) {
      crown = 1;
      star = 3;
    }
    if (ran_nums > 6500) {
      crown = 1;
      star = 4;
    }
    if (ran_nums > 8000) {
      crown = 2;
      star = 0;
    }
    if (ran_nums > 9500) {
      crown = 2;
      star = 1;
    }
    if (ran_nums > 11000) {
      crown = 2;
      star = 2;
    }
    if (ran_nums > 12500) {
      crown = 2;
      star = 3;
    }
    if (ran_nums > 14000) {
      crown = 2;
      star = 4;
    }
    if (ran_nums > 15500) {
      crown = 3;
      star = 0;
    }
    if (ran_nums > 17000) {
      crown = 3;
      star = 1;
    }
    if (ran_nums > 18500) {
      crown = 3;
      star = 2;
    }
    if (ran_nums > 20000) {
      crown = 3;
      star = 3;
    }
    if (ran_nums > 21500) {
      crown = 3;
      star = 4;
    }
    if (ran_nums > 23000) {
      crown = 4;
      star = 0;
    }
    if (ran_nums > 24500) {
      crown = 4;
      star = 1;
    }
    if (ran_nums > 26000) {
      crown = 4;
      star = 2;
    }
    if (ran_nums > 27500) {
      crown = 4;
      star = 3;
    }
    if (ran_nums > 29000) {
      crown = 4;
      star = 4;
    }
    if (ran_nums > 30500) {
      crown = 5;
      star = 0;
    }
    return {
      crown,
      star
    };
  }
  /* 根据数字生成一个数组 */
  createArr(num) {
    let newArr = [];
    for (let i = 0; i < num; i++) {
      newArr[i] = i;
    }
    return newArr;
  }
  /* 把图片名称组成的字符串转换成数组Array */
  strToArr(str, separator) {
    var splitStr = separator || "|";
    var Arr = [];
    if (str) {
      Arr = str.split(splitStr);
    }
    return Arr;
  }
  /*时间转换*/
  checkTime(i) {
    if (i < 10) {
      i = "0" + i;
    }
    return i;
  }
  formatTime(datenum) {
    var date = new Date(datenum * 1000);
    var getFullYear = this.checkTime(date.getFullYear());
    var getMonth = this.checkTime(date.getMonth() + 1);
    var getDate = this.checkTime(date.getDate());
    var getHours = this.checkTime(date.getHours());
    var getMinutes = this.checkTime(date.getMinutes());
    var getSeconds = this.checkTime(date.getSeconds());
    return (
      getFullYear +
      "-" +
      getMonth +
      "-" +
      getDate +
      " " +
      getHours +
      ":" +
      getMinutes +
      ":" +
      getSeconds
    );
  }
}

export default Util;
